using Gateway.IQuery;
using Gateway.IQuery.RequestLog;
using Gateway.IQuery.RequestLog.Request;
using Gateway.IQuery.RequestLog.Result;

namespace Gateway.UI.Api.Controllers;

/// <summary>
/// 请求日志
/// </summary>
public class RequestLogController : BaseController
{
    private readonly IRequestLogQuery _requestLogQuery;

    /// <summary>
    /// 
    /// </summary>
    /// <param name="requestLogQuery"></param>
    public RequestLogController(IRequestLogQuery requestLogQuery)
    {
        _requestLogQuery = requestLogQuery;
    }

    /// <summary>
    /// 获取分页列表
    /// </summary>
    /// <param name="request"></param>
    /// <returns></returns>
    [HttpPost, Route("page")]
    public async Task<PageResult<RequestLogDetailResult>> GetPageList(RequestLogPageRequest request)
    {
        return await _requestLogQuery.GetPage(request);
    }

    /// <summary>
    /// 获取详情
    /// </summary>
    /// <param name="id"></param>
    /// <returns></returns>
    [HttpGet, Route("detail/{id}")]
    public async Task<RequestLogDetailResult> GetDetail([FromRoute] string id)
    {
        return await _requestLogQuery.GetDetail(id);
    }
}